package com.unei.groovy.batch

/**
 * Created by sunlei on 2015/1/14.
 */

class MethodClosureSample{
    int limit

    MethodClosureSample(int limit){
        this.limit=limit
    }

    boolean validate(String value){
        return value.length()<=limit
    }
}

MethodClosureSample first=new MethodClosureSample(6)
MethodClosureSample second=new MethodClosureSample(5)

Closure firstClosure=first.&validate

def words=["long string","medium","short","tiny"]

println(words.find(firstClosure))
println(words.find(second.&validate))